#include "interface/demuxer_plugin.h"

namespace OHOS {
namespace Media {
namespace Plugin {

class Minimp3Demuxer : public PluginBaseImpl, DemuxerPlugin {
public:
    // 只需要实现下面两个
    Status GetMediaInfo(MediaInfo &mediaInfo) override;
    Status ReadFrame(Buffer &buffer, int32_t timeOutMs) override;
    
    // 下面实现可以通用，已经实现
    Status SetDataSource(const std::shared_ptr<DataSource> &source) override;
    size_t GetTrackCount() override;
    Status SelectTrack(int32_t trackId) override;
    Status UnselectTrack(int32_t trackId) override;
    Status GetSelectedTracks(std::vector<int32_t> &trackIds) override;
    Status SeekTo(int32_t trackId, int64_t timeStampUs, SeekMode mode) override;

private:
    class DemuxerPluginAllocator : public Allocator {
    public:
        DemuxerPluginAllocator() = default;
        ~DemuxerPluginAllocator() override = default;
        void* Alloc(size_t size) override;
        void Free(void* ptr) override;
    };

    std::shared_ptr<DataSource> dataSource_;
    std::unique_ptr<MediaInfo> mediaInfo_;
    std::vector<int32_t> selectedTrackIds_;
    OSAL::Mutex mutex_;
};


}
}
}